home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.9 KB | 213 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWShape.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWSHAPE_H
- #include "FWShape.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_Shape
- #endif
-
- FW_DEFINE_AUTO(FW_CShape)
- FW_DEFINE_CLASS_M0(FW_CShape)
-
- //========================================================================================
- // class FW_CShape
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::FW_CShape
- //----------------------------------------------------------------------------------------
-
- FW_CShape::FW_CShape(FW_ERenderVerbs renderVerb,
- const FW_CInk& ink,
- const FW_CStyle& style,
- const FW_CFont& font) :
- fRenderVerb(renderVerb),
- fInk(ink),
- fStyle(style),
- fFont(font)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::FW_CShape
- //----------------------------------------------------------------------------------------
-
- FW_CShape::FW_CShape(const FW_CShape& other):
- fInk(other.fInk),
- fStyle(other.fStyle),
- fFont(other.fFont),
- fRenderVerb(other.GetRenderVerb())
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::FW_CShape
- //----------------------------------------------------------------------------------------
-
- FW_CShape::FW_CShape(FW_CReadableStream& stream)
- {
- stream >> fInk;
- stream >> fStyle;
- stream >> fFont;
- stream.Read((char*)&fRenderVerb, sizeof(fRenderVerb));
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::~FW_CShape
- //----------------------------------------------------------------------------------------
-
- FW_CShape::~FW_CShape()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CShape& FW_CShape::operator=(const FW_CShape& other)
- {
- if (this != &other)
- {
- fInk = other.fInk;
- fStyle = other.fStyle;
- fFont = other.fFont;
- fRenderVerb = other.fRenderVerb;
- }
-
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::Purge
- //----------------------------------------------------------------------------------------
-
- void FW_CShape::Purge()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CShape::Flatten(FW_CWritableStream& stream) const
- {
- stream << fInk;
- stream << fStyle;
- stream << fFont;
- stream.Write((char*)&fRenderVerb, sizeof(fRenderVerb));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::GetUnSharedInk
- //----------------------------------------------------------------------------------------
-
- FW_CInk& FW_CShape::GetUnSharedInk()
- {
- if (fInk.GetRefCount() > 1)
- fInk = fInk.Copy();
-
- return fInk;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::GetUnSharedStyle
- //----------------------------------------------------------------------------------------
-
- FW_CStyle& FW_CShape::GetUnSharedStyle()
- {
- if (fStyle.GetRefCount() > 1)
- fStyle = fStyle.Copy();
-
- return fStyle;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::GetUnSharedFont
- //----------------------------------------------------------------------------------------
-
- FW_CFont& FW_CShape::GetUnSharedFont()
- {
- if (fFont.GetRefCount() > 1)
- fFont = fFont.Copy();
-
- return fFont;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::Write
- //----------------------------------------------------------------------------------------
-
- void FW_CShape::Write(FW_CWritableStream& stream, FW_ClassTypeConstant type, const void *object)
- {
- FW_UNUSED(type);
- ((FW_CShape*)object)->Flatten(stream);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::SetRenderVerb
- //----------------------------------------------------------------------------------------
-
- void FW_CShape::SetRenderVerb(FW_ERenderVerbs renderVerb)
- {
- fRenderVerb = renderVerb;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::SetInk
- //----------------------------------------------------------------------------------------
-
- void FW_CShape::SetInk(const FW_CInk& newInk)
- {
- fInk = newInk;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::SetStyle
- //----------------------------------------------------------------------------------------
-
- void FW_CShape::SetStyle(const FW_CStyle& newStyle)
- {
- fStyle = newStyle;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::SetFont
- //----------------------------------------------------------------------------------------
-
- void FW_CShape::SetFont(const FW_CFont& newFont)
- {
- fFont = newFont;
- }
-
-
-